#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
const int N = 1.5e6+5;
int hd[N],cnt,n,k,ans;bool vis[N];
struct node{int to,nex;}e[N << 1];
inline void add(int u,int v)
{e[++cnt] = {v,hd[u]};hd[u] = cnt;}
bool dfs(int u,int fa,int now,int d)
{
    now += vis[u];
    if(d == k)return now == 1;
    for(int i = hd[u],v;i;i = e[i].nex)
        if((v = e[i].to) != fa)
            if(!dfs(v,u,now,d+1))return 0;
    return 1;
}
void dfs2(int x)
{
    if(x == n+1)
    {
        bool flag = 1;
        for(int i = 1;i <= n;i++)
        if(!dfs(i,0,0,1)){flag = 0;break;}
        ans += flag;
        return ;
    }
    vis[x] = 1;dfs2(x+1);
    vis[x] = 0;dfs2(x+1);
}
char buf[1<<21],*p1,*p2;
inline int rd()
{
    char c;int f = 1;
    while(!isdigit(c = getchar()))if(c=='-')f = -1;
    int x = c-'0';
    while(isdigit(c = getchar()))x = x*10+(c^48);
    return x*f;
}
int main()
{
    freopen("life.in","r",stdin);
    freopen("life.out","w",stdout);
    n = rd();k = rd();
    for(int i = 1;i < n;i++)
    {int u = rd(),v = rd();add(u,v);add(v,u);}
    if(n <= 18)dfs2(1);
    else ans = k;
    puts(ans?"YES":"NO");
    cout << ans << endl;
    return 0;
}